<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>诗词</title>
    <script src="jquery-1.12.4.min.js"></script>
</head>
<body>
    <div class="poetry">
        <h2 class="title"></h2>
        <h3 class="author"></h3>
        <div class="content"></div>
        
    </div>
    <script>
        var title = $('.title');
        var authors=$('.author');
        var content=$('.content');
        
         var xhr=new XMLHttpRequest();
            xhr.open('GET','https://api.apiopen.top/recommendPoetry');
            xhr.send();
            xhr.onreadystatechange=function(){
                //访问状态是数据传输完成
                if(xhr.readyState==XMLHttpRequest.DONE){
                    var obj=JSON.parse(xhr.responseText);
                    $('.title').html(obj.result.title);
            
                    $('.author').html(obj.result.authors);
            
                    $('.content').html(obj.result.content.replace(/\|/g,'<br/>'));
                
               
            }
        }
    
    
    </script>
</body>
</html>